18a7eba5a0f12bd74487c0fc41678dfafc65f04b,styx-cli/src/main/java/com/spotify/styx/cli/Main.java,Main,backfillEdit,#,226

Before Change


  private void backfillEdit() {
    final Integer concurrency = namespace.getInt(parser.backfillEditConcurrency.getDest());
    final String id = namespace.getString(parser.backfillEditId.getDest());
    final Request getRequest = Request.forUri(apiUrl("backfills", id));

    byte[] getResponse = send(getRequest);
    final BackfillPayload backfillPayload;
    try {
      backfillPayload = OBJECT_MAPPER.readValue(getResponse, BackfillPayload.class);
    } catch (IOException e) {
      e.printStackTrace();
      return;
    }

    Backfill editedBackfill = backfillPayload.backfill();
    if (concurrency != null) {
      editedBackfill = backfillPayload.backfill().builder().concurrency(concurrency).build();
    }
    final ByteString putPayload;
    try {
      putPayload = ByteString.of(OBJECT_MAPPER.writeValueAsBytes(editedBackfill));
    } catch (JsonProcessingException e) {
      throw Throwables.propagate(e);
    }
    final Request putRequest = Request.forUri(apiUrl("backfills", id), "PUT").withPayload(putPayload);
    byte[] putResponse = send(putRequest);

    final Backfill newBackfill;
    try {
      newBackfill = OBJECT_MAPPER.readValue(putResponse, Backfill.class);
    } catch (IOException e) {
      e.printStackTrace();
      return;

After Change


    final Integer concurrency = namespace.getInt(parser.backfillEditConcurrency.getDest());
    final String id = namespace.getString(parser.backfillEditId.getDest());

    final ByteString getResponse = send(Request.forUri(apiUrl("backfills", id)));
    final BackfillPayload backfillPayload = deserialize(getResponse, BackfillPayload.class);
    final BackfillBuilder editedBackfillBuilder = backfillPayload.backfill().builder();
    if (concurrency != null) {
      editedBackfillBuilder.concurrency(concurrency);
    }
    final ByteString putPayload = serialize(editedBackfillBuilder.build());
    final ByteString putResponse = send(
        Request.forUri(apiUrl("backfills", id), "PUT").withPayload(putPayload));

    final Backfill newBackfill = deserialize(putResponse, Backfill.class);
    cliOutput.printBackfill(newBackfill);
  }